package com.chinacoal.microservice.api;

import java.util.List;
import java.util.Map;

import javax.validation.Valid;

import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.baomidou.mybatisplus.plugins.Page;
import com.chinacoal.microservice.api.fallback.UnionTaskMaintainClientFallback;
import com.chinacoal.microservice.api.model.QueryUtaskParam;
import com.chinacoal.microservice.api.model.UtaskCompleteTaskParam;
import com.chinacoal.microservice.api.model.entity.UtaskInfoEntity;
import com.chinacoal.microservice.util.result.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @Description: 待办中心管理接口
 * @author linp
 * @date 2019年11月29日 下午7:22:36
 * @version V1.0
 */
@Api(tags = {"统一待办中心管理接口"})
@FeignClient(name = "ccms-union-task", configuration = FeignAutoConfiguration.class, fallback = UnionTaskMaintainClientFallback.class)
public interface UnionTaskMaintainClient {
	
    @ApiOperation("新增待办信息")
    @PostMapping("/uniontask/task/add")
    public Result<Object> addTask(@Valid @RequestBody UtaskInfoEntity utaskInfoEntity);
    
    @ApiOperation("批量新增待办信息")
    @PostMapping("/uniontask/task/battchTaskAdd")
    public Result<Map<String,List<UtaskInfoEntity>>> battchTaskAdd(@Valid @RequestBody List<UtaskInfoEntity> utaskInfoList);
	
    @ApiOperation("修改待办信息")
    @PutMapping("/uniontask/task/update")
    public Result<Object> updateTask(@Valid @RequestBody UtaskInfoEntity utaskInfoEntity);
    
    @ApiOperation("修改已办信息")
    @PutMapping("/uniontask/task/updateAchTask")
    public Result<Object> updateAchTask(@Valid @RequestBody UtaskInfoEntity utaskInfoEntity);
    
    @ApiOperation("批量修改待办信息")
    @PutMapping("/uniontask/task/battchUpdate")
    public Result<Object> battchUpdateTask(@Valid @RequestBody List<UtaskInfoEntity> utaskInfoList);
    
    @ApiOperation("完成待办审批处理")
    @PostMapping("/uniontask/task/completeTask")
    public Result<Object> completeTask(@Valid @RequestBody UtaskCompleteTaskParam param);
    
    @ApiOperation("批量完成待办审批处理")
    @PostMapping("/uniontask/task/battchCompleteTask")
    public Result<Map<String,List<String>>> battchCompleteTask(@Valid @RequestBody List<UtaskCompleteTaskParam> paramList);
    
    @ApiOperation("取消未审批待办")
    @PostMapping("/uniontask/task/cancelTask")
    public Result<Object> cancelTask(@Valid @RequestBody UtaskCompleteTaskParam param);
    
    @ApiOperation("取消已审批待办")
    @PostMapping("/uniontask/task/cancelAchTask")
    public Result<Object> cancelAchTask(@Valid @RequestBody UtaskCompleteTaskParam param);
    
    @ApiOperation("批量取消未审批待办")
    @PostMapping("/uniontask/task/battchCancelTask")
    public Result<Map<String,List<String>>> battchCancelTask(@Valid @RequestBody List<UtaskCompleteTaskParam> paramList);
    
    @ApiOperation("强制修改待办状态")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType="query", name = "sysCode", value = "应用系统编码", required = true, dataType = "String"),
        @ApiImplicitParam(paramType="query", name = "sysTaskId", value = "待办Id", required = true, dataType = "String"),
        @ApiImplicitParam(paramType="query", name = "state", value = "待办状态", required = true, dataType = "String")
    })
    @GetMapping("/uniontask/task/updateTaskState")
    public Result<Object> updateTaskState(@RequestParam("sysCode") String sysCode, 
			 							  @RequestParam("sysTaskId") String sysTaskId,
			 							  @RequestParam("state") String state);
    
    @ApiOperation("获取待办详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "sysCode", value = "应用系统编码", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "sysTaskId", value = "待办Id", required = true, dataType = "String"),
    })
    @GetMapping("/uniontask/task/getTask")
    public Result<UtaskInfoEntity> getTask(@RequestParam("sysCode") String sysCode, 
    								 	   @RequestParam("sysTaskId") String sysTaskId);
    
    @ApiOperation("查询当前用户待办列表")
    @PostMapping("/uniontask/task/getTaskInfoList")
    public Result<Page<UtaskInfoEntity>> getTaskInfoList(@Valid @RequestBody QueryUtaskParam param);
    
    @ApiOperation("查询当前用户待办数量")
    @PostMapping("/uniontask/task/getTaskInfoListNum")
    public Result<Object> getTaskInfoListNum(@Valid @RequestBody QueryUtaskParam param);
    
    @ApiOperation("根据用户和系统查询待办数量")
    @PostMapping("/uniontask/task/selectTaskCountList")
    public Result<Object> selectTaskCountList(@Valid @RequestBody QueryUtaskParam param);
    
    @ApiOperation("获取待办状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "sysCode", value = "应用系统编码", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "sysTaskId", value = "待办Id", required = true, dataType = "String"),
    })
    @GetMapping("/uniontask/task/getTaskState")
    public Result<Object> getTaskState(@RequestParam("sysCode") String sysCode, 
    								   @RequestParam("sysTaskId") String sysTaskId);
    
    @ApiOperation("待办收藏 / 取消收藏处理")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType="query", name = "userCode", value = "用户id", required = true, dataType = "String"),
        @ApiImplicitParam(paramType="query", name = "taskId", value = "主键id", required = true, dataType = "String"),
        @ApiImplicitParam(paramType="query", name = "sysCodeFrom", value = "来源系统", required = true, dataType = "String"),
        @ApiImplicitParam(paramType="query", name = "flag", value = "0：取消，1：收藏", required = true, dataType = "String"),
    })
    @GetMapping("/uniontask/task/collectTask")
    public Result<Object> collectTask(@RequestParam("userCode") String userCode, 
    								  @RequestParam("taskId") String taskId,
                                      @RequestParam("sysCodeFrom") String sysCodeFrom, 
                                      @RequestParam("flag") String flag);
}
